<?php
/**
 * Subcategoryadmin_Data_Addsubcategory
 * add subcategory temmplate data
 * @author Adrian Stolarski
 */
class Subcategoryadmin_Data_Addsubcategory implements Subcategoryadmin_Data_Mainable, 
        Subcategoryadmin_Data_Preparable, Subcategoryadmin_Data_Templatable, 
        Subcategoryadmin_Data_Tokenable{
    
    /**
     *
     * @var type $database
     * database handler
     */
    public $database;
    /**
     *
     * @var type $database_query 
     * database query handler
     */
    public $database_query;
    /**
     *
     * @var type $random token
     * random token handler
     */
    public $random_token;
    /**
     *
     * @var type $all_categories_data
     * all categories data handler
     */
    public $all_categories_data;
    
    /**
     * constructor();
     */
    public function __construct() {
        $this->database = new Core_Driver_MysqlImproved;
        $this->random_token = new Core_Data_Tokenizer;
        $this->all_categories_data = new Core_Controller_Maincategorydata;
    }
    
    /**
     * create_token()
     * create random token
     * 
     * @return type Core_Data_Tokenizer
     */
    public function create_token() {
        return $this->random_token->create_token();
    }
    
    /**
     * get_template_name()
     * return current tempalte name
     * 
     * @return string $template
     */
    public function get_template_name() {
        $template = SERVER_ROOT."subcategoryadmin/views/addsubcategory.php";
        return $template;
    }
    
    /**
     * main()
     * create add sub category template data
     * @param array $variables
     * @return type $page
     */
    public function main(array $variables = null) {
        //var_dump($variables);
        //die();
        //$page = $array();
        $page['template'] = $this->get_template_name();
        $page['csrf_token'] = $this->create_token();
        $page['main_category_data'] = $this->all_categories_data->main(null);
        //var_dump($page);
        //die();
        return $page;
    }
    
    /**
     * prapapre_query()
     * prepare database query
     * @param array $variables
     */
    public function prepare_query(array $variables = null) {
       $this->database_query = "SELECT * FROM page_sub_category;"; 
    }

}
